package BusinessLogic;

/**
 * 		   Result class represents a result in the system. It holds a
 *         ResultType state variable representing the success/failure result, as
 *         well as the returned object in the case of success or an error
 *         message in case of a failure.
 */
public class Result {
  public enum ResultType {
    SUCCESS, FAILURE
  }
  
  private ResultType resultType;
  private Object successReturnValue=null;
  private String failureMessage= null;
  
  Result(ResultType resultType, Object additionalInformation) {
    this.resultType = resultType;
    if (resultType == ResultType.SUCCESS) {
      this.successReturnValue = additionalInformation;
    } else {
    	if (additionalInformation instanceof String)
    		this.failureMessage = (String) additionalInformation;
    	else
    		this.successReturnValue = additionalInformation;
    }
  }
  
  public ResultType getResultType() {
    return resultType;
  }
  
  public Object getSuccessReturnValue() {
    return successReturnValue;
  }
  
  public String getFailureMessage() {
    return failureMessage;
  }
  
  public Object getFailureReturnValue() {
	    return successReturnValue;
	  }
}
